<?php

namespace App\Libs\Upload;

use App\Libs\Upload\Base;

class Image extends Base
{
    /**
     * fileType 文件类型
     * @var string
     */
    public $fileType =  "image";
    public $maxSize = 128;
    public $fileExtTypes = ['jpg', 'jpeg', 'png'];

    public function file()
    {
        $request = $this->request();
        $video = $request->getUploadedFile('file');
        $flag = $video->moveTo('/home/easySwoole/App/Uploads/1.txt');
        $data = [
            'url' => '1.txt',
            'flag' => $flag
        ];
        if ($flag) {
            return $this->writeJson(200, $data, 'success');
        } else {
            return $this->writeJson(400, $data, 'failed');
        }
    }
}